package net.alche.al.util.far;

import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;

import net.alche.al.util.Far;
import net.alche.fa.core.SageStone;
import net.alche.fa.core.model.FaValue;

@SuppressWarnings("all") 
public class FaBaseSage {
  public String toJsonTxt(SageStone sage) {
    Map mp = sageToMap(sage);
    return Far.tl.toJsonTxt(mp);
  }

  public Map sageToMap(SageStone sage) {
    Map mp = new HashMap<>();
    if (sage.getVars() != null && !sage.getVars().isEmpty()) {
      for (Entry<String,FaValue> item : sage.getVars().entrySet()) {
        mp.put(item.getKey(), item.getValue().getJava());
      }
    }
    return mp;
  }
}
